This page contains the complete Wapapi API as well as
function declarations for PowerBuilder and Delphi. To plug Wapapi
into your application, there are three areas that you will need to
address: listening for web requests, getting information about the
request, and constructing and returning a web page.
The first step in using Wapapi is to start listening for web requests.
Wapapi uses Windows' messaging system to inform a window in your
application that a web request has been received. The function calls
in this section are for setting up this messaging as well as
for logging any received requests (useful in profiling the use of
your web/application server), and to stop listening for
web requests. The StartServing and
StopServing calls should be used in all
applications. The EnableLogging and
DisableLogging should be used
only if you are interested in profiling the usage of your web/application
server.
StartServingDescription:
This function is used to start Wapapi, start accepting web requests, and
tells Wapapi what window and event you will be using to handle web requests.
All web requests will trigger this event on the window. The port number
should be 80, or higher than 80 if you are using Wapapi with another
server. The IP address is used only on NT servers that have multiple
IP addresses, otherwise pass '0.0.0.0' for this parameter.
Usage:
This function should be called from the open event of the window that you
want to receive web requests.
Delphi Declaration:
function StartServing(winhandle :word; imessage :integer; pipaddress :pchar; iport :integer) :integer; stdcall; external 'wapapi.dll';
PB Declaration:
function int StartServing(uint winhandle, int imessage, string sipaddress, int iport) LIBRARY 'Wapapi';
StopServingDescription:
This function will stop Wapapi from responding to web requests and
closes the Wapapi DLL. Usage:
This function should be called when your window is about to close.
Delphi Declaration:
function StopServing :integer; far; stdcall; external 'wapapi.dll';
PB Declaration
function int StopServing() LIBRARY 'Wapapi'
EnableLoggingDescription:
Starts logging the pages hit, client addresses, and date/times of hits.
Data from logging can be accessed by hitting the page: www/admin on the
running server.
Usage:
This function should be called right after the StartServing call.
Delphi Declaration:
procedure EnableLogging(pFile :pchar; bKeepHistory :boolean; ilogSize :integer); far; stdcall; external 'wapapi.dll';
PB Declaration
subroutine EnableLogging(string sFile, boolean bKeepHistory, int ilogSize) LIBRARY 'Wapapi'
DisableLoggingDescription:
Stops logging the hit informationand writes all current data to the log file.
Usage:
This function should be called right before the StopServing call, but is
optional. If it is not called, all log information will still be saved.
Delphi Declaration:
procedure DisableLogging(); far; stdcall; external 'wapapi.dll';
PB Declaration
subroutine DisableLogging() LIBRARY 'Wapapi'
When your application receives a web request, you must get some information
about the request so that you can build a response. The functions in this
section let you get this information. GetDocName
should be called first to determine what the name of the requested document
is. GetParm and GetParmString
can be used if your application is receiving HTML form information
from a GET or POST.
These calls should all be used in the window event that you
have specified to receive web requests.
GetDocNameDescription: This function returns the name of the document that is currently
being requested.
Usage:
This function should be called from the event on your window that is
responding to web requests. The string: sDoc must be allocated
before calling this function. user StrAlloc in Delphi or assign
it as Space(255) in Powerbuilder. The iParms parameter returns the
number of parameters that were passed with the document (used with
HTML forms). Use the GetParm function to return the values of
these parameters.
Delphi Declaration:
function GetDocName(pDoc :pchar; var iParms :integer) :integer; stdcall; external 'wapapi.dll';
PB Declaration:
function int GetDocName(string sDoc,int iParms) LIBRARY "Wapapi";
GetParmDescription:
This function is used to get parameters that were passed with a document
as part of an HTML form being submitted. Pass it the parameter number
to retrieve, and the name of the parameter and the parameter's value will
be returned.
Usage:
Call this function after a GetDocName function call that indicates that
parameters have been passed. Pre-allocate the parm name and parm value
strings before making the call.
Delphi Declaration:
function GetParm(liParmNumber :integer; lpParmName, lpParmValue :pchar) :integer; far; stdcall; external 'wapapi.dll';
PB Declaration:
function int GetParm(int iParmNumber, ref string sParmName, ref string sParmValue) LIBRARY 'Wapapi';
GetParmStringDescription:
This function is used to get parameters from a submitted HTML form by
using the name of the parameter. Pass it the parameter's name to
retrieve, and the parameter's value will be returned.
Usage:
Call this function after a GetDocName function call that indicates that
parameters have been passed. Pre-allocate the parm value string before
making the call.
Delphi Declaration:
function GetParmString(lpParmName, lpParmValue :pchar) :integer; far; stdcall; external 'wapapi.dll';
PB Declaration:
function int GetParmString(ref string sParmName, ref string sParmValue) LIBRARY 'Wapapi';
After you have gotten information about the requested document,
you need to either build a web page and send it to the requestor
or designate that a file should be sent to the requestor. Use
SendDocument to send a file from your disk drive,
or use BufferText and then
SendText to build a web page dynamically.
These function calls can be located either in the window event that you have
specified to receive all web requests, or in a function that is called from
this event.
SendDocumentDescription:
This function is used to send an HTML document or
a graphics file from your local disk to the web requestor. It sends
the file and then closes the request.
Usage:
Just call this function with the desired file. Wapapi will search
for the file in the directory designated in the Wapapi.INI file.
Delphi Declaration:
function SendDocument(pDocName :pchar) :integer; far; stdcall; external 'wapapi.dll';
PB Declaration:
function int SendDocument(ref string sDocName) LIBRARY 'Wapapi';
BufferTextDescription:
This function is used to add text to a buffer in Wapapi. This
buffer will later be sent as a complete document when the SendText
function is called.
Usage:
Use this function to build a document in Wapapi's buffer space.
You can buffer as much text as your computer has memory, but keep
each string passed to 64k or below.
Delphi Declaration:
function BufferText(pText :pchar) :integer; far; stdcall; external 'wapapi.dll';
PB Declaration: function int BufferText(ref string sText) LIBRARY 'Wapapi';
SendTextDescription: This function sends whatever is in Wapapi's buffer space to
the web requestor and closes the request.
Usage:
Use this call as the last line in your window that
processes web requests, after you have built the document using the
BufferText function.
Delphi Declaration:
function SendText :integer; far; stdcall; external 'wapapi.dll';
PB Declaration:
function int SendText() LIBRARY 'Wapapi';